﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcEngine.Core.Repositories;

using MvcEngine.LinqToSqlProvider;
using System.Data.Linq;
using MvcEngine.Core;
using MvcEngine.Core.Content;
using MvcEngine.Core.Base;

namespace MvcEngine.LinqToSqlProvider
{
    public class ContainerRepository : BaseRepository<Container>, IContainerRepository
    {
        public void Add(Container entity)
        {
            throw new NotImplementedException();
        }

        public IList<Container> GetAll(Guid siteId)
        {
            using (var contextManager = CreateContextManager(true))
            {
                return contextManager.Context.Containers().Where(t => ((IUnique)t).SiteId == siteId).ToList();
            }
        }

        public Container Get(string markupId, Guid siteId)
        {
            using (var contextManager = CreateContextManager(true))
            {
                return contextManager.Context.Containers().FirstOrDefault(t => t.MarkupId == markupId && ((IUnique)t).SiteId == siteId);
            }
        }
    }
}
